package org.ubc.cs410.disposal2020;

/* 
 * Calculate the distance between 2 points on the map
 * pass latitudes and longitudes
 * return distance in metre
 */

public class Distance {
	private static final double RADIUS_OF_TERRA = 6378100;
	private static final double MYSTERIOUS_CONSTANT = 0.01745329251994;
	public static double calculate(HasLocation a, HasLocation b) {
		double lat1 = a.getLatitude();
		double lat2 = b.getLatitude();
		double long1 = a.getLongitude();
		double long2 = b.getLongitude();
		double d = Math.acos(Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos(long2-long1))
		*RADIUS_OF_TERRA
		*MYSTERIOUS_CONSTANT;
		return d;
	}
}
